home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: watzka@stat.uni-muenchen.de (Kurt Watzka)
- Newsgroups: comp.lang.c
- Subject: Re: C compiling question
- Date: 3 Mar 1996 15:57:07 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4hcfgj$1qn@sparcserver.lrz-muenchen.de>
- References: <3138D53F.41C6@mashie.ece.jhu.edu>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- Chenyang Xu <chenyang@mashie.ece.jhu.edu> writes:
-
- >Hi, there,
-
- >===foo1.c===
- >#include "stdio.h"
- >#include "math.h"
-
- >void print_msg1()
- >{
- > float x = 1.0;
- > float y;
- >
- > y = exp(x);
- > printf("foo1.c\n");
- > printf("%f\n", y);
-
- > return;
- >}
-
- >===foo2.c===
- >void print_msg2()
- >{
- > printf("foo2.c\n");
- > print_msg1();
- > return;
- >}
-
- >My question is how the print_msg2() knows print_msg1() and carrys out
- >the result
- > without causing a compiling or linking error or warning,
-
- Since there is no declaration for print_msg1() in foo2.c, the compiler
- _must_ assume that print_msg1() is a function taking no parameters
- and returning int. It must compile your program. It _should_ print
- a diagnostic telling you that it has made the abovementioned assumption.
-
- You are lucky that there is no difference in the calling sequence of
- a function returning an int and a function _not_ returning anything
- in your implementation. So, don't try this "trick" in an implementation
- with different calling schemes.
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
- | ua302aa@sunmail.lrz-muenchen.de
-